//
//  LocalTopicSource.m
//  YoursShow
//
//  Created by Roc on 11-4-12.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "LocalTopicSource.h"

#import "LocalPhotoTopic.h"

@implementation LocalTopicSource 

@synthesize topics = _topics;

- (id)init {
    if ((self = [super init])) {
        return self;
    }
    
    return nil;
}

- (NSInteger)numberOfTopics {
    if (_topics) {
        return _topics.count;
    } else {
        return 0;
    }
}

- (id<Topic>)topicAtIndex:(NSInteger)index {
    if (index < _topics.count) {
        id topic = [_topics objectAtIndex:index];
        if (topic == [NSNull null]) {
            return nil;
        } else {
            return topic;
        }
    } else {
        return nil;
    }
}

- (void)loadTopics {
    _topics = [NSMutableArray array];
    
    LocalPhotoTopic* topic;
    for(int i = 0; i < 12; i++) {
        topic = [[LocalPhotoTopic alloc] init];
        topic.title = [NSString stringWithFormat:@"Topic %d", i+1];
        topic.src = [NSString stringWithFormat:@"%d.jpg", i+1];
        [_topics addObject:topic];
        [topic release];
    }
}
@end
